<?php

/**
 * 首页焦点图修改AJAX
 * 
 * @copyright zhanghuan
 * @since 2012-03-23
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/index/db_food_focus_pic_index.class.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;

	//id
	cgi::both($g_cgival["id"], "id", 0);
	$g_cgival["id"] = intval($g_cgival["id"]);
	
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show;
	$id = $g_cgival["id"];
	
	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();
	$admin_id = admin::admin_get_login_uid();
	$admin_name = admin::admin_get_login_user_name();	
	
	$db = new db_food_focus_pic_index();
	if ($id > 0)
	{
		// 获取焦点图信息
		$data = $db->admin_get_item_by_id($site_id, $id);
		$g_show["data"] = $data;
	}
}

try
{
	admin_check_login();
	
	check_cgi_pro();
	get_data();
	
	$g_show["error"] = 0;
	$g_show["errmsg"] = '';
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;

function show_pro()
{
	global $g_show;

	
	$smarty = p_get_smarty ();
	$smarty->assign ("g_show", $g_show);
// 	print_r($smarty);
	$smarty->display ( "foodv2/index/focus_pic_edit.html" );
}
?>